package com.leo;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Slider;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;

/**
 * @ClassName BindingDemo
 * @Description
 * @Author wangss
 * @date 2020.05.29 11:41
 * @Version 1.0
 */
public class Binding3Demo extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        AnchorPane anchorPane = new AnchorPane();
        anchorPane.setStyle("-fx-background-color: #e7eeea");
        Scene scene = new Scene(anchorPane);

        Button button = new Button("button");

        Slider slider = new Slider();

        slider.setPrefWidth(300d);

        anchorPane.getChildren().addAll(button, slider);

        AnchorPane.setTopAnchor(slider, 100d);

        primaryStage.setScene(scene);
        primaryStage.setTitle("binding");
        primaryStage.setWidth(625d);
        primaryStage.setHeight(500d);
        primaryStage.setResizable(false);
        primaryStage.show();

        button.translateXProperty().bind(slider.valueProperty());
    }
}

